<?php

/* 
 * Clase UpdateOrder
 * Jorge
 */

class UpdateOrder {

    var $unit_value_without_tax;
    var $unit_discounted_value;
    var $unit_tax_value;
    var $quantity;
    var $total_discounted_value;
    var $total_tax_value;
    var $total_gross_value;

    public function __construct() {
        $this->unit_value_without_tax = 0;
        $this->unit_discounted_value = 0;
        $this->unit_tax_value = 0;
        $this->quantity = 0;
        $this->total_discounted_value = 0;
        $this->total_tax_value = 0;
        $this->total_gross_value = 0;
    }

    public function setUnitValues($unit_value,$tax,$discount,$quantity) {
        $this->unit_value_without_tax = $unit_value/(1+($tax/100));
        $this->unit_discounted_value = $this->unit_value_without_tax*$discount/100;
        $this->unit_tax_value = ($this->unit_value_without_tax-$this->unit_discounted_value)*($tax/100);
        $this->quantity = $quantity;
    }

    public function getDiscountedValue() {
        $discounted_value = round($this->unit_discounted_value*$this->quantity,2);
        $this->total_discounted_value = $this->total_discounted_value + $discounted_value;
        return $discounted_value;
    }

    public function getTaxValue() {
        $tax_value = round($this->unit_tax_value*$this->quantity,2);
        $this->total_tax_value = $this->total_tax_value + $tax_value;
        return $tax_value;
    }

    public function getGrossValue() {
        $gross_value = round($this->unit_value_without_tax*$this->quantity,2);
        $this->total_gross_value = $this->total_gross_value + $gross_value;
        return $gross_value;
    }

    public function getTotalDiscountedValue() {
        return $this->total_discounted_value;
    }

    public function getTotalTaxValue() {
        return $this->total_tax_value;
    }

    public function getTotalGrossValue() {
        return $this->total_gross_value;
    }
}